//忘记密码
//登录
<template>
  <div class="login">
    <div class="left">
      <p>非学无以广才，</p>
      <p>非志无以成学</p>
      <img src="../assets/29.png" alt="" />
    </div>
    <div class="right">
      <p class="title">考试网登录</p>
      <p class="post">忘记密码</p>
      <el-form ref="form" :model="form">
        <el-form-item
          ><el-input
            v-model="form.userPhone"
            placeholder="请输入手机号码"
          ></el-input>
        </el-form-item>
        <el-form-item class="flex">
          <div class="code">
            <el-input
            placeholder="验证码"
            name="code"
            class="txt"
            v-model="form.code"
          ></el-input>
          </div>
          <div class="obtain">
            <div v-show="verShow">
            <el-button @click="GetCode()" type="primary">获取验证码</el-button>
          </div>
          <div v-show="!verShow">
            <el-button disabled type="info"
              ><span>{{ timer }}</span
              >秒后重新获取</el-button
            >
          </div>
          </div>
          
        </el-form-item>
        <el-form-item><el-input
            placeholder="请输入新密码"
            v-model="form.newpassword"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item><el-input
            placeholder="确认密码"
            v-model="form.firmpassword"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="confirm()" class="button"
            >确认</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {
        userPhone: "",
        newpassword: "",
        firmpassword: "",
        code: "",
      },
      // checked: true,
      verShow: true, // 判断显示那个按钮
      timer: 60, // 短信验证码倒计时
    };
  },
  methods: {
    GetCode() {
      const regEmali = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
      if (regEmali.test(this.form.userPhone) == true) {
        this.verShow = false;
        const authTimer = setInterval(() => {
          this.timer--;
          if (this.timer <= 0) {
            this.verShow = true;
            this.timer = 60;
            clearInterval(authTimer);
          }
        }, 1000);
      } else {
        this.$message.error("请输入正确手机号");
      }
    },




    //点击登录调用方法
    confirm() {
      //保存的手机号
      var phone = this.form.userPhone;
      //验证码
      var code = this.form.code
      //新密码
      var newpass = this.form.newpassword;
      //确认新密码
      var firmpass = this.form.firmpassword;
      if (phone == "" || phone == null) {
        this.$message.error("请输入正确的手机号");
        return;
      } else if (code == "" || code == null) {
        this.$message.error("请输入验证码");
        return;
      } else if (newpass == "" || newpass == null) {
        this.$message.error("请输入新密码");
        return;
      } else if (firmpass !== newpass) {
        this.$message.error("确认密码需与新密码一致");
        return;
      } else {
        localStorage.removeItem("Authorization");
        //  this.$router.push("/Index")
        // console.log(name)
        this.$router.push("/Login");
      }
    },
  },
  //页面加载调用获取cookie值
  mounted() {
    // this.getCookie(); // chrome
    document.body.scrollTop = 0;
    // firefox
    document.documentElement.scrollTop = 0;
    // safari
    window.pageYOffset = 0;
  },
};
</script>
<style lang="scss" scoped>
.login {
  min-width: 1366px;
  width: 100%;
  background: url("../assets/500813050.png") no-repeat left top;
  background-size: cover;
  -webkit-background-size: cover;
  -o-background-size: cover;
  height: 100%;
  position: fixed;
  display: flex;
  justify-self: unset;
  justify-content: space-around;
  flex-wrap: wrap;
  .left {
    width: 723px;
    color: #fff;
    font-size: 35px;
    text-align: center;
    // background: olivedrab;
    margin-top: 16%;
    p {
      width: 100%;
      margin: 0 auto;
      line-height: 60px;
    }
    p:nth-child(2) {
      text-indent: 8rem;
    }
    img {
      width: 723px;
      margin-top: 40px;
    }
  }
  .right {
    margin-top: 9%;
    width: 480px;
    height: 589px;
    background: #ffffff;
    box-shadow: 0px 30px 28px 4px rgba(8, 2, 3, 0.17);
    border-radius: 20px;
    .title {
      color: #1269ff;
      font-size: 31px;
      line-height: 31px;
      text-align: center;
      margin-top: 48px;
      margin-bottom: 77px;
    }
    .post {
      width: 14%;
      margin: 20px 0px 20px 11%;
      // text-indent: 1rem;
      line-height: 40px;
      border-bottom: 2px solid #1269ff;
    }
    .el-form {
      width: 80%;
      margin: 0 auto;
      margin-top: 40px;
      .el-form-item {
        width: 100%;
        
        .el-input {
          width: 100%;
          
          // background: #1269FF !important;
        }
        .button {
          width: 90%;
          margin: 0 auto;
          margin-left: 5%;
          margin-top: 20px;
        }
      }
    }
  }
}

.flex {
  .el-form-item__content {
    width: 100%;
  //  display: flex;
  // justify-content: space-between;
  background: #f00;
  >.code {
    width: 50%;
    float: left;
  }
  >.obtain {
    width: 39%;
    float: right;
    button {
      width: 100%;
    }
  } 

  }

  
}
</style>